package com.frinder.base.wx;

import lombok.Builder;
import lombok.Getter;
import lombok.ToString;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @ClassName SystemMessage
 * @Description //TODO
 * @Author frinder
 * @Date 2019/1/19 17:39
 * @Version 1.0
 */
@ToString
@Builder
@Getter
public class SystemMessage {

    private static final DateTimeFormatter FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    public enum Level {
        SUCCESS,
        INFO,
        WARNING,
        ERROR
    }

    public enum Type {
        IN,
        OUT
    }

    private String traceId;
    private String taskId;
    private Level level;
    private Object content;
    private Type type;
    private String time;

    public static SystemMessage message(String traceId,
                                        String taskId,
                                        Level level,
                                        Type type,
                                        Object content) {
        return SystemMessage.builder()
                .traceId(traceId)
                .taskId(taskId)
                .level(level)
                .type(type)
                .content(content)
                .time(LocalDateTime.now().format(FORMATTER))
                .build();
    }

}
